﻿package II.controls {
	
	import flash.display.*;
	
	public class UISinglePanel extends UIBase {

		public function UISinglePanel() {
			// constructor code
		}

		
		// CONTENT 
		
		public function get content() : UIBase {
			return _content;
		}
		public function set content ( value:UIBase ) : void {
			if ( _content != null ) {
				this.removeChild( _content );
			}
			_content = value;
			if ( _content != null ) {
				this.addChild( _content );
			}
		}		
		var _content:UIBase = null;
		
		// CONTENT
		
		
				
		// MASK
		
		public function get isMasked() : Boolean {
			return _isMasked;
		}
		public function set isMasked(value:Boolean) : void {
			if ( value == _isMasked ) return;
			_isMasked = value;
			this.updateMask();
		}
		var _isMasked:Boolean = false;
		
		override public function updateLayout() : void {
			this.updateLayoutAllChild();
			this.updateMask();
		}
		
		private function updateMask () {
			if ( Size.IsEmpty(this.size) == true ) return;
			if ( this.mask != null ) {
				this.removeChild(this.mask);
				this.mask = null;
			}
			if ( this.isMasked == true ) {
				var maskerShape : Shape = new Shape();
				maskerShape.graphics.beginFill(0x0);
				maskerShape.graphics.drawRect(0, 0, this.size.width, this.size.height);
				maskerShape.graphics.endFill();
				addChild(maskerShape);
				this.mask = maskerShape;
			}
		}
		
		// MASK 
		
	}
	
}
